﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;

public class StageClearTrigger : MonoBehaviour
{
    SpriteRenderer spriteRenderer;
    private void Awake()
    {
        spriteRenderer = GetComponent<SpriteRenderer>();

    }
    float alpha;
    private void Update()
    {
        alpha = Mathf.PingPong(Time.time, 0.5f);
        Color c = spriteRenderer.color;
        c.a = alpha + 0.5f;
        spriteRenderer.color = c;
    }
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (GameManager.Instance.GameState != Constants.GameState_Lose && collision.CompareTag("Player"))
        {
            GameManager.Instance.GameState = Constants.GameState_Win;
            GameManager.Instance.ShowWinMessageBox();
        }
    }

}
